<?php

namespace App\Console\Commands\Mybank;

use App\Kuafu\Mybank\Model\MybankBillRecordModel;
use App\Kuafu\Mybank\Service\MybankOrderWithholdService;
use App\Kuafu\Mybank\Service\MybankService;
use App\Kuafu\Order\Model\OrderCouponSplitModel;
use App\Kuafu\Order\Model\OrderDetailSplitModel;
use App\Kuafu\Order\Model\OrderDiscountSplitModel;
use App\Kuafu\Order\Model\OrderExternalSplitModel;
use App\Kuafu\Order\Model\OrderPayUnionSplitModel;
use App\Kuafu\Order\Model\OrderSplitModel;
use App\Kuafu\Pay\Model\PayStreamModel;
use App\Kuafu\Shop\Model\Shop;
use App\Kuafu\Shop\Service\ShopService;
use App\Kuafu\WaiMai\Model\WaiMaiOrderDetailModel;
use App\Kuafu\WaiMai\Model\WaiMaiOrderIdShopIdMappingModel;
use App\Kuafu\WaiMai\Model\WaiMaiOrderModel;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class QueryMerchantBrokerageCommand extends Command
{
    protected $signature = 'mybank:query-merchant-brokerage';

    protected $description = '网商获取商户总账单数据';

    public function handle()
    {
        $shopId = 15019;

        $billTimeList        = [
            [
                'startAt' => strtotime('2023-09-01'), // 年月日
                'endAt'   => strtotime('2023-09-21'), // 年月日
            ]
        ];
        $source              = MybankBillRecordModel::SOURCE_MEITUAN;
        $calcOrderBrokerSum1 = (string)MybankOrderWithholdService::calcBrokerSum($shopId, $billTimeList, $source);
        $source              = MybankBillRecordModel::SOURCE_ELE;
        $calcOrderBrokerSum2 = (string)MybankOrderWithholdService::calcBrokerSum($shopId, $billTimeList, $source);
        $source              = MybankBillRecordModel::SOURCE_CANTEEN;
        $calcOrderBrokerSum3 = (string)MybankOrderWithholdService::calcBrokerSum($shopId, $billTimeList, $source);

        $shopInfo = ShopService::getShopInfo($shopId);
        dump('当前门店信息:' . $shopInfo->name);
        dump('美团:' . $calcOrderBrokerSum1);
        dump('饿了么:' . $calcOrderBrokerSum2);
        dump('堂食:' . $calcOrderBrokerSum3);
        dump('总计:' . ($calcOrderBrokerSum1 + $calcOrderBrokerSum2 + $calcOrderBrokerSum3));

    }
}
